<template>
	<!-- <TableModal ref='tableModalRef' :config='config' :search='searchConfig' :table='tableConfig'/> -->
</template>

<script setup>
	/* --------------------------- Component --------------------------- */
	// const TableModal 	= $.lazy(()=>import('#cpt/temp/TableModal.vue'))
	/* ---------------------------  ref --------------------------- */
	// ref: tableModalRef
	/* --------------------------- Event --------------------------- */
	const emit = defineEmits(['select'])
	/* --------------------------- config --------------------------- */
	const config = {
		modalWidth: '90%',
		modalHeight: '80%',
		title: '选择工作令',
		// drawer: true,
		footer: false
	}
	/* ---------------------------  搜索 Search --------------------------- */
	ref: exeStatusData = []
	ref: manageTypeData = []
	ref: productBandTypeData = []
	ref: businessTypeData = []
	const searchConfig = {
		data: [
			{ label:'工作令名', 		name:'workContent' },
			{ label:'工作令编号', 	name:'workTokenCode' },
			{ label:'责任人', 		name:'userChargeCN' },
			{ label:'研制方式', 		name:'researchType', 	type:'select', api:'system/dict/data/type/business_workToken_researchType', idStr:'dictValue', nameStr:'dictLabel' },
			{ label:'产品频段', 		name:'manageType', 		type:'select', api:'system/dict/data/type/business_common_productBandType', idStr:'dictValue', nameStr:'dictLabel',
				getData: data => productBandTypeData = data
			},
			{ label:'管理类型', 		name:'manageType', 		type:'select', api:'system/dict/data/type/business_workToken_manageType', idStr:'dictValue', nameStr:'dictLabel',
				getData: data => manageTypeData = data
			},
			{ label:'执行状态', 		name:'exeStatus', 		type:'select', api:'system/dict/data/type/business_workToken_exeStatus', idStr:'dictValue', nameStr:'dictLabel' ,
				getData: data => exeStatusData = data
			},
			{ label:'归集状态', 		name:'collectStatus', 	type:'select', api:'system/dict/data/type/business_workToken_collectStatus', idStr:'dictValue', nameStr:'dictLabel'  },
			{ label:'创建时间', 		name:'jz-time', 		type:'date-range' }
		]
	}
	/* ---------------------------  Table --------------------------- */
	const tableConfig = {
		api 		: 'business/workToken/list',
		cols 		: [
			{ title: '序号', 		dataIndex: 'seqNum', 				...$fn.table.seqNum },
			{ title: '工作令号', 	dataIndex: 'workTokenCode', 		width:150 },
			// { title: '工作令名', 	dataIndex: 'workContent', 			width:100, customRender:({ text, record }) => $fn.table.popDetail({ tableRef, id:record.workTokenId, config:listConfig, text }) },
			{ title: '工作令名', 	dataIndex: 'workContent', 			width:100, customRender:({ text, record  }) => $fn.table.push('/main/project/instruct/detail', { id:record.workTokenId, businessKey:record.businessKey }, text, router) },
			{ title: '所属项目', 	dataIndex: 'proName', 				width:100 },
			{ title: '产品型号', 	dataIndex: 'productModel', 			width:100 },
			{ title: '单位', 		dataIndex: 'units', 				width:100 },
			{ title: '数量', 		dataIndex: 'count', 				width:100 },
			{ title: '管理类型', 	dataIndex: 'manageType', 			...$fn.table.four, customRender:({ text }) => $fn.getState(manageTypeData, text, {v:'dictValue', n:'dictLabel'}) },
			{ title: '产品频段', 	dataIndex: 'productBandType', 		...$fn.table.four, customRender:({ text }) => $fn.getState(productBandTypeData, text, {v:'dictValue', n:'dictLabel'}) },
			{ title: '业务类别', 	dataIndex: 'businessType', 			...$fn.table.four, customRender:({ text }) => $fn.getState(businessTypeData, text, {v:'dictValue', n:'dictLabel'}) },
			{ title: '产品类别', 	dataIndex: 'productType', 			...$fn.table.four, customRender:({ text }) => $fn.getState(businessTypeData, text, {v:'dictValue', n:'dictLabel'}) },
			{ title: '责任部门', 	dataIndex: 'deptChargeCN', 			...$fn.table.four },
			{ title: '负责人', 		dataIndex: 'userChargeCN', 			width:150 },
			// { title: '执行状态', 	dataIndex: 'exeStatus', 			...$fn.table.status },
			{ title: '执行状态', 	dataIndex: 'exeStatus', 			...$fn.table.four, customRender:({ text }) => $fn.getState(exeStatusData, text, {v:'dictValue', n:'dictLabel'}) },
			{ title: '要求交期', 	dataIndex: 'deliveryDate', 			...$fn.table.time },
			{ title: '计划交期', 	dataIndex: 'planCompleteTime', 		...$fn.table.time },
			{ title: '实际完成时间', dataIndex: 'reallyCompleteTime',		...$fn.table.time },
			{ title: '录入时间', 	dataIndex: 'createTime', 			...$fn.table.time },
			{ ...$fn.table.control, width:100 }
		],
		controls 	: rows => [
			{ label:'选择工作令', click:()=> {
				if(rows){
					emit('select', rows)
					window.$tableModalRef().close()
				}
			} }
		]
	}
	/* --------------------------- 通信 --------------------------- */
	defineExpose({
		open: () => window.$tableModalRef().open({ config, table:tableConfig, search:searchConfig })
	})
</script>
